package com.demo.webflux.redis;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
public class ArticleService {

	@Autowired
	private ArticleReactiveRedisRepository articleReactiveRedisRepository;

	public Mono<Boolean> saveArticle(Article article){
		return articleReactiveRedisRepository.saveArticle(article);
	}

	public Mono<Boolean> updateArticle(Article article){
		return articleReactiveRedisRepository.updateArticle(article);
	}

	public Mono<Boolean> deleteArticle(String id){
		return articleReactiveRedisRepository.deleteArticle(id);
	}

	public Mono<Serializable> findArticleById(String id){
		return articleReactiveRedisRepository.findArticleById(id).log("findOneArticle");
	}

	public Flux<Serializable> findAllArticles(){
		return articleReactiveRedisRepository.findAllArticles().log("findAllArticles");
	}

}
